home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
moden
/
adterm.int
< prev
next >
Wrap
Text File
|
1996-04-08
|
17KB
|
504 lines
{Conditional defines that may affect this unit}
{$I AWDEFINE.INC}
{Required options}
{$I+,G+,X+,F+}
{$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
{*********************************************************}
{* ADTERM.PAS 1.01 *}
{* Copyright (c) TurboPower Software 1995 *}
{* All rights reserved. *}
{*********************************************************}
unit AdTerm;
{-Delphi terminal window component}
interface
uses
{-----RTL}
SysUtils,
Classes,
Messages,
WinTypes,
WinProcs,
Controls,
StdCtrls,
Forms,
DsgnIntf,
Graphics,
{-----APD}
OoMisc,
{$IFNDEF UseAPWDLL}
AwUser,
AwEmu,
AwTerm,
{$ENDIF}
AdExcept,
AdPort,
AdProtcl;
{$IFDEF UseAPWDLL}
{$I AWEMU.PA0} {ANSI emulator}
{$I AWTERM.PA0} {Terminal window control}
{$ENDIF}
{Emulator constants from OOMISC}
const
{Emulator commands}
eNone = 0; {No command, ignore this char}
eChar = 1; {No command, process the char}
eGotoXY = 2; {Absolute goto cursor position call}
eUp = 3; {Cursor up}
eDown = 4; {Cursor down}
eRight = 5; {Cursor right}
eLeft = 6; {Cursor left}
eClearBelow = 7; {Clear screen below cursor}
eClearAbove = 8; {Clear screen above cursor}
eClearScreen = 9; {Clear entire screen}
eClearEndofLine = 10; {Clear from cursor to end of line}
eClearStartOfLine= 11; {Clear from cursor to the start of line}
eClearLine = 12; {Clear entire line that cursor is on}
eSetMode = 13; {Set video mode}
eSetBackground = 14; {Set background attribute}
eSetForeground = 15; {Set foreground attribute}
eSetAttribute = 16; {Set video attribute (foreground and background)}
eSaveCursorPos = 17; {Save cursor position}
eRestoreCursorPos= 18; {Restore cursor position}
eDeviceStatusReport = 19; {Report device status or cursor position}
eString = 20; {Pascal style string S[10]}
eError = 255; {indicates a parser error}
{Extended attributes}
eattrBlink = $01;
eattrInverse = $02;
eattrIntense = $04;
eattrInvisible = $08;
eattrUnderline = $10;
{ANSI color constants}
emBlack = 0;
emRed = 1;
emGreen = 2;
emYellow = 3;
emBlue = 4;
emMagenta = 5;
emCyan = 6;
emWhite = 7;
emBlackBold = 8;
emRedBold = 9;
emGreenBold = 10;
emYellowBold = 11;
emBlueBold = 12;
emMagentaBold = 13;
emCyanBold = 14;
emWhiteBold = 15;
type
{For setting auto-scrollbar behavior}
TAutoScroll = (asNone, asHorizontal, asVertical, asBoth);
TIntegralSize = (isNone, isWidth, isHeight, isBoth);
{Emulator types}
TEmulatorType = (etNone, etANSI);
{Capture mode}
TCaptureMode = (cmOff, cmOn, cmAppend);
{Status event handler}
TTerminalStatusEvent = procedure(CP : TObject;
Row, Col : Byte;
BufRow, BufCol : Word) of object;
const
{Default emulator property values}
DefEmuData = nil;
DefEmulatorType = etAnsi;
{Default terminal property values}
DefComPort = nil;
DefEmulator = nil;
DefControlStyles = [csClickEvents, csSetCaption, csFramed, csDoubleClicks];
DefWidth = 200;
DefHeight = 200;
DefTabStop = True;
DefParentColor = False;
DefParentFont = False;
DefStyle = 0;
DefScrollBars = ssNone;
DefAutoScroll = asNone;
DefTermSave = nil;
DefIntegralSize = isBoth;
DefScrollback = False;
DefActive = True;
DefColor = clBlue;
DefFontColor = clYellow;
DefRows = 200;
DefColumns = 80;
DefPageHeight = 25;
DefDisplayRows = 15;
DefDisplayColumns = 40;
DefCapture = cmOff;
DefCaptureFile = 'APD.CAP';
DefFontName = 'Terminal';
DefWantTabs = True;
DefBPlusTriggers = False;
type
{$I OOMISC.PA3} {Contains types for OOTERM/ADTERM}
{Emulator process char event}
TProcessCharEvent = procedure(CP : TObject;
C : Char;
var Command : TEmuCommand) of object;
{The base emulator component}
TApdCustomEmulator = class(TComponent)
protected {private}
{.Z+}
FEmuInUse : Bool; {!!.01}
FEmuData : Pointer;
FEmuProc : TProcessCharProc;
FEmulatorType : TEmulatorType;
FOnProcessChar : TProcessCharEvent;
protected
procedure SetEmuData(NewEmu : Pointer);
procedure SetEmuProc(NewProc : TProcessCharProc);
procedure SetEmulatorType(const NewEmulatorType : TEmulatorType);
procedure Loaded; override;
procedure ProcessChar(C : Char; var Command : TEmuCommand); virtual;
public
constructor Create(AOwner : TComponent); override;
{-Create a TApdEmulator component}
{.Z-}
property EmulatorType : TEmulatorType
read FEmulatorType write SetEmulatorType default DefEmulatorType;
property OnProcessChar : TProcessCharEvent
read FOnProcessChar write FOnProcessChar;
property EmuData : Pointer
read FEmuData write SetEmuData;
property EmuProc : TProcessCharProc
read FEmuProc write SetEmuProc;
property EmuInUse : Bool {!!.01}
read FEmuInUse write FEmuInUse; {!!.01}
end;
{The emulator component}
TApdEmulator = class(TApdCustomEmulator)
published
property EmulatorType;
property OnProcessChar;
end;
{The base terminal window component}
TApdCustomTerminal = class(TWinControl)
protected {private}
{.Z+}
{Misc}
TermSave : Pointer;
Created : Boolean;
ActivePending : Boolean;
Force : Boolean;
WasFullWidth : Boolean;
PixelWidth : Word;
InRecreate : Boolean;
{Property fields}
FComPort : TApdCustomComPort;
FStyle : LongInt;
FScrollBars : TScrollStyle;
FAutoScroll : TAutoScroll;
FIntegralSize : TIntegralSize;
FScrollBack : Boolean;
FActive : Boolean;
FEmulator : TApdCustomEmulator;
FRows : Word;
FColumns : Word;
FPageHeight : Word;
FDisplayRows : Word;
FDisplayColumns : Word;
FCaptureFile : String;
FCapture : TCaptureMode;
FOnTerminalStatus : TTerminalStatusEvent;
{Colors}
ColorMap : TAnsiColorMap;
{Private procedures}
procedure StuffDesignData;
procedure SetComPort(const NewComPort : TApdCustomComPort);
procedure SetEmulator(const NewEmulator : TApdCustomEmulator);
procedure SetName(const Value: TComponentName); override;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
{Font procedures}
procedure PassFont;
procedure CMFontChanged(var Message : TMessage); message CM_FONTCHANGED;
{Color procedures}
function ColorIndex(const RGB : TColor) : Integer;
function CurrentColor(const Back : Boolean) : Integer;
procedure GetColorMap;
procedure SetColorMap;
procedure PassColors;
procedure CMColorChanged(var Message : TMessage); message CM_COLORCHANGED;
{Open/close messages}
procedure PortOpen(var Message : TMessage); message APW_PORTOPEN;
procedure PortClose(var Message : TMessage); message APW_PORTCLOSE;
{Terminal activation}
function StartTerminalPrim(UseExcept : Boolean) : Integer;
procedure StartTerminal; dynamic;
function StopTerminalPrim(UseExcept : Boolean) : Integer;
procedure StopTerminal; dynamic;
protected
{Property methods}
procedure CreateWnd; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure SetScrollBars(const NewScroll : TScrollStyle);
procedure SetAutoScroll(const NewScroll : TAutoScroll);
procedure SetIntegralSize(const NewInt : TIntegralSize);
procedure SetScrollback(const NewScroll : Boolean);
procedure SetActive(const NewActive : Boolean);
procedure SetRows(const NewRows : Word);
procedure SetColumns(const NewColumns : Word);
procedure SetPageHeight(const NewPageHeight : Word);
function GetDisplayRows : Word;
procedure SetDisplayRows(const NewRows : Word);
function GetDisplayColumns : Word;
procedure SetDisplayColumns(const NewColumns : Word);
function GetWantTabs : Boolean;
procedure SetWantTabs(const NewTabs : Boolean);
function GetHeight : Integer;
procedure SetHeight(const NewHeight : Integer);
function GetWidth : Integer;
procedure SetWidth(const NewWidth : Integer);
function GetCharWidth : Byte;
function GetCharHeight : Byte;
procedure SetCapture(const NewCapture : TCaptureMode);
procedure SetCaptureFile(const NewFile : String);
{Event methods}
procedure TerminalStatus(Row, Col : Byte; BufRow, BufCol : Word); virtual;
{Message methods}
procedure apwTermStatus(var Message : TMessage); message APW_TERMSTATUS;
{Other protected methods}
procedure PassBuffer;
procedure GetTermState;
procedure SetTermState;
procedure RecreateWnd;
procedure WndProc(var Message: TMessage); override;
procedure Notification(AComponent : TComponent;
Operation: TOperation); override;
procedure Loaded; override;
public
{Creation/destruction}
constructor Create(AOwner : TComponent); override;
{-Create a TApdTerminal component}
destructor Destroy; override;
{-Destroy a TApdTerminal component}
{.Z-}
{Other public properties}
procedure ClearWindow;
{-Clear the visible window by performing a page-down operation}
procedure ClearBuffer;
{-Clear the entire buffer}
procedure StuffChar(const C : Char);
{-Add the character C to the current location in the terminal window}
procedure StuffString(const S : String);
{-Add the string S to the current location in the terminal window}
procedure ForcePaint;
{-Update the terminal display, required after StuffChar or StuffString}
procedure CopyToClipboard;
{-Copy the marked block to the clipboard}
procedure SetColors(const FC, BC : Byte);
{-Set the foreground and background colors for new data}
property CharWidth : Byte
read GetCharWidth;
property CharHeight : Byte
read GetCharHeight;
protected {published}
property ComPort : TApdCustomComPort
read FComPort write SetComPort;
property Active : Boolean
read FActive write SetActive default DefActive;
property ScrollBars : TScrollStyle
read FScrollBars write SetScrollBars default DefScrollBars;
property AutoScroll : TAutoScroll
read FAutoScroll write SetAutoScroll default DefAutoScroll;
property IntegralSize : TIntegralSize
read FIntegralSize write SetIntegralSize default DefIntegralSize;
property Scrollback : Boolean
read FScrollback write SetScrollback default DefScrollback;
property Emulator : TApdCustomEmulator
read FEmulator write SetEmulator;
property Rows : Word
read FRows write SetRows default DefRows;
property Columns : Word
read FColumns write SetColumns default DefColumns;
property PageHeight : Word
read FPageHeight write SetPageHeight default DefPageHeight;
property DisplayRows : Word
read GetDisplayRows write SetDisplayRows default DefDisplayRows;
property DisplayColumns : Word
read GetDisplayColumns write SetDisplayColumns default DefDisplayColumns;
property CaptureFile : String
read FCaptureFile write SetCaptureFile;
property Capture : TCaptureMode
read FCapture write SetCapture default DefCapture;
property WantTabs : Boolean
read GetWantTabs write SetWantTabs default DefWantTabs;
{.Z+}
{Override these so we can get to SetWidth/SetHeight}
property Height : Integer
read GetHeight write SetHeight;
property Width : Integer
read GetWidth write SetWidth;
{.Z-}
{Events}
property OnTerminalStatus : TTerminalStatusEvent
read FOnTerminalStatus write FOnTerminalStatus;
end;
{The terminal window component}
TApdTerminal = class(TApdCustomTerminal)
published
{Publish the terminal window properties}
property ComPort;
property Active;
property ScrollBars;
property AutoScroll;
property IntegralSize;
property Scrollback;
property Emulator;
property Rows;
property Columns;
property PageHeight;
property DisplayRows;
property DisplayColumns;
property CaptureFile;
property Capture;
property WantTabs;
property Height;
property Width;
property OnTerminalStatus;
{Published inherited properties}
property Align;
property Color default DefColor;
property Ctl3d;
property Cursor;
property Enabled;
property Font;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property Visible;
{Published inherited events}
property OnClick;
property OnDblClick;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
{B+ Terminal}
TApdCustomBPTerminal = class(TApdCustomTerminal) {!!.01}
protected {private}
{.Z+}
TimerIndex : Word; {B+ timer trigger handle}
EnqTrig : Word; {ENQ trigger handle}
DLETrig : Word; {DLE trigger handle}
EscITrig : Word; {<ESC>I trigger handle}
Started : Boolean; {True if B+ started}
ProcessingDLE : Boolean; {True when processing a DLE sequence}
Protocol : TApdProtocol; {B+ protocol component}
FBPlusTriggers: Boolean; {Sets triggers on/off}
FOnBPlusStart : TNotifyEvent; {Event handler for B+ starts}
protected
procedure SetBPlusTriggers(const OnOff : Boolean);
procedure CreateWnd; override;
procedure apwTriggerTimer(var Msg : TMessage); message APW_TRIGGERTIMER;
procedure apwTriggerLength(var Msg : TMessage); message APW_TRIGGERAVAIL;
procedure apwTriggerData(var Msg : TMessage); message APW_TRIGGERDATA;
procedure apwBPlusStart(var Msg : TMessage); message APW_TERMBPLUSSTART;
function FoundDLE : Boolean;
procedure Notification(AComponent : TComponent;
Operation: TOperation); override;
public
constructor Create(AOwner : TComponent); override;
{-Create a TApdBPTerminal}
{.Z-}
property OnBPlusStart : TNotifyEvent
read FOnBPlusStart write FOnBPlusStart;
property BPlusTriggers : Boolean
read FBPlusTriggers write SetBPlusTriggers default DefBPlusTriggers;
end;
{B+ Terminal}
TApdBPTerminal = class(TApdCustomBPTerminal)
published
property ComPort;
property Active;
property ScrollBars;
property AutoScroll;
property IntegralSize;
property Scrollback;
property Emulator;
property Rows;
property Columns;
property PageHeight;
property DisplayRows;
property DisplayColumns;
property CaptureFile;
property Capture;
property Align;
property Color default DefColor;
property Ctl3d;
property Enabled;
property Font;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property Visible;
property WantTabs; {!!.01}
property OnClick;
property OnDblClick;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnBPlusStart;
property OnTerminalStatus; {!!.01}
end;
procedure Register;